package com.axjy.web;

import com.axjy.pojo.Group;
import com.axjy.service.GroupService;
import java.util.List;

import com.axjy.util.Log;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by zjn on 2018/1/30.
 */
@RestController
@RequestMapping("/cys/group")
public class GroupHandler {

   @Resource
   private GroupService groupService;


   @GetMapping("/list")
    public List<Group> list(){
        return groupService.list();
    }

    @PostMapping("/add")
    public String add(String groupName){
        String msg=null;
        try{
            groupService.add(groupName);
            msg="新增分组成功";
        }catch (RuntimeException ex){
            msg="新增分组失败";
            Log.logger.error(msg,ex);
        }
            return msg;
    }



}
